﻿Public Class Wfrm_Log_Carga
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If Not Page.IsPostBack Then

            Dim DSProceso As New DataSet

            Dim cadenaCon As String = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & Session("archivo") & ";Extended Properties=""Excel 12.0 Xml;HDR=YES"";"
            Dim con As OleDb.OleDbConnection = New OleDb.OleDbConnection(cadenaCon)
            con.Open()
            Dim adaptador1 As New OleDb.OleDbDataAdapter("SELECT count(1) FROM [PERSONAL$] ", con)
            adaptador1.Fill(DSProceso, "XLData")
            con.Close()

            If Not DSProceso.Tables(0) Is Nothing Then
                lbl_total.Text = DSProceso.Tables(0).Rows(0).Item(0)
            End If
            'SP_GET_UP_LOG
            'ruta
            Dim exec As New DotNetDal.SQLPersistence(False, "cnn", DotNetDal.SQLPersistence.Provider.SQLCLIENT)
            Dim rp As New DotNetResponse.SQLPersistence
            rp.StoredProcedure = "SP_GET_UP_LOG"
            rp.AddParametro(Session("archivo"))
            exec.ExecuteDataTable(rp)
            DataGrid1.DataSource = rp.DtTable
            DataGrid1.DataBind()

            If rp.TieneDatos Then
                Dim i As Integer
                lbl_advertencia.Text = 0
                lbl_errores.Text = 0

                For i = 0 To rp.DtTable.Rows.Count - 1
                    If rp.DtTable.Rows(i).Item(1).ToString = "A" Then

                        lbl_advertencia.Text = lbl_advertencia.Text + 1
                    Else
                        lbl_errores.Text = lbl_errores.Text + 1
                    End If
                Next

                For i = 0 To DataGrid1.Items.Count - 1
                    If DataGrid1.Items(i).Cells(1).Text = "E" Then
                        DataGrid1.Items(i).BackColor = Drawing.Color.LightBlue
                        DataGrid1.Items(i).ForeColor = Drawing.Color.Maroon
                    End If
                Next
            End If

        End If
    End Sub

End Class